//package com.zhw.controller;
//
//import com.zhw.util.EasyPoiUtils;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//
//import javax.servlet.http.HttpServletResponse;
//import javax.validation.Valid;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
///**
// * @author:weizhang
// * @date: 2020-11-04
// * @modify:
// * @des:
// */
//public class DemoController {
//
//    @Autowired
//    private StatisticsService statisticsService;
//
//    /**
//     * 设备时间分布统计-excel导出
//     *
//     * @param deviceTimeMap 请求参数:起止时间
//     * @param response
//     */
//    @GetMapping("/exportDeviceTimeDistributionByDay")
//    public void getDeviceTimeDistributionByDay(@RequestParam @Valid Map<String, String> deviceTimeMap, HttpServletResponse response) {
//
//        log.info("[exportDeviceTimeDistributionByDay] 设备使用时间分布统计excel导出,入参deviceTimeMap={}", deviceTimeMap);
//        String startDay = deviceTimeMap.get("startDay");
//        String endDay = deviceTimeMap.get("endDay");
//        // 根据请求参数查询导出的数据
//        DeviceTimeDistributionDTO deviceTimeDistributionDTO = (DeviceTimeDistributionDTO) statisticsService
//                .getDeviceTimeDistributionByDay(deviceTimeMap).getData();
//        log.info("[exportDeviceTimeDistributionByDay] 查询的导出数据deviceTimeDistributionDTO={}", deviceTimeDistributionDTO);
//        // 导出的excel数据集合
//        List<DeviceTimeDistributionExcelDTO> deviceTimeDistributionExcelList = getDeviceTimeDistributionExcelDTOS(deviceTimeDistributionDTO);
//        long timestamp = System.currentTimeMillis();
//        // excel标题
//        String excelTitle = CommonConstants.EXCEL_NAME_DT_DAY + CommonConstants.LEFT_BRACKET + startDay
//                + CommonConstants.WORD_ZHI + endDay + CommonConstants.RIGHT_BRACKET;
//        // excel文件名称:文件名+时间戳+格式后缀
//        String excelName = CommonConstants.EXCEL_NAME_DT_DAY + timestamp + CommonConstants.EXCEL_SUFFIX;
//        // 导出:自定义导出属性
//        EasyPoiUtils.exportExcel(deviceTimeDistributionExcelList, excelTitle, CommonConstants.EXCEL_SHEET_DAY,
//                DeviceTimeDistributionExcelDTO.class, excelName, response);
//
//    }
//
//    /**
//     * 活跃用户按天统计-excel导出
//     *
//     * @param activeUserDayMap 请求参数:起止时间
//     * @param response
//     */
//    @GetMapping("/exportActiveUserByDay")
//    public void exportActiveUserByDay(@RequestParam @Valid Map<String, String> activeUserDayMap, HttpServletResponse response) {
//
//        log.info("[exportActiveUserByDay] 活跃用户按天统计excel导出,入参deviceTimeMap={}", activeUserDayMap);
//        String startDay = activeUserDayMap.get("startDay");
//        String endDay = activeUserDayMap.get("endDay");
//        // 根据请求参数查询导出的数据
//        List<DayStatisticsDto> dayStatisticsDtoList = (List<DayStatisticsDto>) statisticsService
//                .getActiveUserByDay(activeUserDayMap).getData();
//        log.info("[exportActiveUserByDay] 查询的导出数据dayStatisticsDtoList={}", dayStatisticsDtoList);
//        // 导出的excel数据集合
//        List<DayStatisticsExcelDTO> dayStatisticsExcelDTOList = new ArrayList<>();
//        for (DayStatisticsDto dayStatisticsDto : dayStatisticsDtoList) {
//            DayStatisticsExcelDTO dayStatisticsExcelDTO = new DayStatisticsExcelDTO();
//            BeanUtils.copyProperties(dayStatisticsDto, dayStatisticsExcelDTO);
//            dayStatisticsExcelDTOList.add(dayStatisticsExcelDTO);
//        }
//        long timestamp = System.currentTimeMillis();
//        // excel标题
//        String excelTitle = CommonConstants.EXCEL_NAME_ACTIVE_USER_DAY + CommonConstants.LEFT_BRACKET + startDay
//                + CommonConstants.WORD_ZHI + endDay + CommonConstants.RIGHT_BRACKET;
//        // excel文件名称:文件名+时间戳+格式后缀
//        String excelName = CommonConstants.EXCEL_NAME_ACTIVE_USER_DAY + timestamp + CommonConstants.EXCEL_SUFFIX;
//        // 导出:自定义导出属性
//        EasyPoiUtils.exportExcel(dayStatisticsExcelDTOList, excelTitle, CommonConstants.EXCEL_SHEET_DAY,
//                DayStatisticsExcelDTO.class, excelName, response);
//
//    }
//
//    /**
//     * 活跃用户按月统计-excel导出
//     *
//     * @param activeUserMonthMap 请求参数:起止时间
//     * @param response
//     */
//    @GetMapping("/exportActiveUserByMonth")
//    public void exportActiveUserByMonth(@RequestParam @Valid Map<String, String> activeUserMonthMap, HttpServletResponse response) {
//
//        log.info("[exportActiveUserByMonth] 活跃用户按月统计excel导出,入参activeUserMonthMap={}", activeUserMonthMap);
//        String startMonth = activeUserMonthMap.get("startMonth");
//        String endMonth = activeUserMonthMap.get("endMonth");
//        // 根据请求参数查询导出的数据
//        List<MonthStatisticsDto> monthStatisticsDtoList = (List<MonthStatisticsDto>) statisticsService
//                .getActiveUserByMonth(activeUserMonthMap).getData();
//        log.info("[exportActiveUserByMonth] 查询的导出数据monthStatisticsDtoList={}", monthStatisticsDtoList);
//        // 导出的excel数据集合
//        List<MonthStatisticsExcelDTO> monthStatisticsExcelDTOList = new ArrayList<>();
//        for (MonthStatisticsDto monthStatisticsDto : monthStatisticsDtoList) {
//            MonthStatisticsExcelDTO monthStatisticsExcelDTO = new MonthStatisticsExcelDTO();
//            BeanUtils.copyProperties(monthStatisticsDto, monthStatisticsExcelDTO);
//            monthStatisticsExcelDTOList.add(monthStatisticsExcelDTO);
//        }
//        long timestamp = System.currentTimeMillis();
//        // excel标题
//        String excelTitle = CommonConstants.EXCEL_NAME_ACTIVE_USER_MONTH + CommonConstants.LEFT_BRACKET + startMonth
//                + CommonConstants.WORD_ZHI + endMonth + CommonConstants.RIGHT_BRACKET;
//        // excel文件名称:文件名+时间戳+格式后缀
//        String excelName = CommonConstants.EXCEL_NAME_ACTIVE_USER_MONTH + timestamp + CommonConstants.EXCEL_SUFFIX;
//        // 导出:自定义导出属性
//        EasyPoiUtils.exportExcel(monthStatisticsExcelDTOList, excelTitle, CommonConstants.EXCEL_SHEET_MONGTH,
//                MonthStatisticsExcelDTO.class, excelName, response);
//
//    }
//
//    /**
//     * 用户活跃度按天统计-excel导出
//     *
//     * @param userActivationDayMap 请求参数:起止时间
//     * @param response
//     */
//    @GetMapping("/exportUserActivationByDay")
//    public void exportUserActivationByDay(@RequestParam @Valid Map<String, String> userActivationDayMap, HttpServletResponse response) {
//
//        log.info("[exportUserActivationByDay] 活跃用户按天统计excel导出,入参userActivationDayMap={}", userActivationDayMap);
//        String startDay = userActivationDayMap.get("startDay");
//        String endDay = userActivationDayMap.get("endDay");
//        // 根据请求参数查询导出的数据
//        List<DayStatisticsDto> dayStatisticsDtoList = (List<DayStatisticsDto>) statisticsService
//                .getUserActivationByDay(userActivationDayMap).getData();
//        log.info("[exportUserActivationByDay] 查询的导出数据dayStatisticsDtoList={}", dayStatisticsDtoList);
//        // 导出的excel数据集合
//        List<DayStatisticsExcelDTO> dayStatisticsExcelDTOList = new ArrayList<>();
//        for (DayStatisticsDto dayStatisticsDto : dayStatisticsDtoList) {
//            DayStatisticsExcelDTO dayStatisticsExcelBO = new DayStatisticsExcelDTO();
//            BeanUtils.copyProperties(dayStatisticsDto, dayStatisticsExcelBO);
//            dayStatisticsExcelDTOList.add(dayStatisticsExcelBO);
//        }
//        long timestamp = System.currentTimeMillis();
//        // excel标题
//        String excelTitle = CommonConstants.EXCEL_NAME_USER_ACTIVATION_DAY + CommonConstants.LEFT_BRACKET + startDay
//                + CommonConstants.WORD_ZHI + endDay + CommonConstants.RIGHT_BRACKET;
//        // excel文件名称:文件名+时间戳+格式后缀
//        String excelName = CommonConstants.EXCEL_NAME_USER_ACTIVATION_DAY + timestamp + CommonConstants.EXCEL_SUFFIX;
//        // 导出:自定义导出属性
//        EasyPoiUtils.exportExcel(dayStatisticsExcelDTOList, excelTitle, CommonConstants.EXCEL_SHEET_DAY,
//                DayStatisticsExcelDTO.class, excelName, response);
//
//    }
//
//    /**
//     * 用户活跃度按月统计-excel导出
//     *
//     * @param userActivationMonthMap 请求参数:起止时间
//     * @param response
//     */
//    @GetMapping("/exportUserActivationByMonth")
//    public void exportUserActivationByMonth(@RequestParam @Valid Map<String, String> userActivationMonthMap, HttpServletResponse response) {
//
//        log.info("[exportUserActivationByMonth] 用户活跃度按月统计excel导出,入参userActivationMonthMap={}", userActivationMonthMap);
//        String startMonth = userActivationMonthMap.get("startMonth");
//        String endMonth = userActivationMonthMap.get("endMonth");
//        // 根据请求参数查询导出的数据
//        List<MonthStatisticsDto> monthStatisticsDtoList = (List<MonthStatisticsDto>) statisticsService
//                .getUserActivationByMonth(userActivationMonthMap).getData();
//        log.info("[exportUserActivationByMonth] 查询的导出数据monthStatisticsDtoList={}", monthStatisticsDtoList);
//        // 导出的excel数据集合
//        List<MonthStatisticsExcelDTO> monthStatisticsExcelDTOList = new ArrayList<>();
//        for (MonthStatisticsDto monthStatisticsDto : monthStatisticsDtoList) {
//            MonthStatisticsExcelDTO monthStatisticsExcelDTO = new MonthStatisticsExcelDTO();
//            BeanUtils.copyProperties(monthStatisticsDto, monthStatisticsExcelDTO);
//            monthStatisticsExcelDTOList.add(monthStatisticsExcelDTO);
//        }
//        long timestamp = System.currentTimeMillis();
//        // excel标题
//        String excelTitle = CommonConstants.EXCEL_NAME_USER_ACTIVATION_MONTH + CommonConstants.LEFT_BRACKET + startMonth
//                + CommonConstants.WORD_ZHI + endMonth + CommonConstants.RIGHT_BRACKET;
//        // excel文件名称:文件名+时间戳+格式后缀
//        String excelName = CommonConstants.EXCEL_NAME_USER_ACTIVATION_MONTH + timestamp + CommonConstants.EXCEL_SUFFIX;
//        // 导出:自定义导出属性
//        EasyPoiUtils.exportExcel(monthStatisticsExcelDTOList, excelTitle, CommonConstants.EXCEL_SHEET_MONGTH,
//                MonthStatisticsExcelDTO.class, excelName, response);
//
//    }
//
//    /**
//     * 组装24小时统计数据
//     *
//     * @param deviceTimeDistributionDTO
//     * @return
//     */
//    private List<DeviceTimeDistributionExcelDTO> getDeviceTimeDistributionExcelDTOS(DeviceTimeDistributionDTO deviceTimeDistributionDTO) {
//
//        List<DeviceTimeDistributionExcelDTO> deviceTimeDistributionExcelList = new ArrayList<>();
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel0 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel0.setHourPeriod(CommonConstants.ZERO_HOUR_PERIOD);
//        deviceTimeDistributionExcel0.setCount(deviceTimeDistributionDTO.getZeroPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel0);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel1 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel1.setHourPeriod(CommonConstants.ONE_HOUR_PERIOD);
//        deviceTimeDistributionExcel1.setCount(deviceTimeDistributionDTO.getOnePeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel1);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel2 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel2.setHourPeriod(CommonConstants.TWO_HOUR_PERIOD);
//        deviceTimeDistributionExcel2.setCount(deviceTimeDistributionDTO.getTwoPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel2);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel3 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel3.setHourPeriod(CommonConstants.THREE_HOUR_PERIOD);
//        deviceTimeDistributionExcel3.setCount(deviceTimeDistributionDTO.getThreePeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel3);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel4 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel4.setHourPeriod(CommonConstants.FOUR_HOUR_PERIOD);
//        deviceTimeDistributionExcel4.setCount(deviceTimeDistributionDTO.getFourPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel4);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel5 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel5.setHourPeriod(CommonConstants.FIVE_HOUR_PERIOD);
//        deviceTimeDistributionExcel5.setCount(deviceTimeDistributionDTO.getFivePeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel5);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel6 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel6.setHourPeriod(CommonConstants.SIX_HOUR_PERIOD);
//        deviceTimeDistributionExcel6.setCount(deviceTimeDistributionDTO.getSixPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel6);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel7 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel7.setHourPeriod(CommonConstants.SEVEN_HOUR_PERIOD);
//        deviceTimeDistributionExcel7.setCount(deviceTimeDistributionDTO.getSevenPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel7);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel8 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel8.setHourPeriod(CommonConstants.EIGHT_HOUR_PERIOD);
//        deviceTimeDistributionExcel8.setCount(deviceTimeDistributionDTO.getEightPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel8);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel9 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel9.setHourPeriod(CommonConstants.NINE_HOUR_PERIOD);
//        deviceTimeDistributionExcel9.setCount(deviceTimeDistributionDTO.getNinePeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel9);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel10 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel10.setHourPeriod(CommonConstants.TEN_HOUR_PERIOD);
//        deviceTimeDistributionExcel10.setCount(deviceTimeDistributionDTO.getTenPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel10);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel11 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel11.setHourPeriod(CommonConstants.ELEVLEN_HOUR_PERIOD);
//        deviceTimeDistributionExcel11.setCount(deviceTimeDistributionDTO.getElevenPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel11);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel12 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel12.setHourPeriod(CommonConstants.TWELVE_HOUR_PERIOD);
//        deviceTimeDistributionExcel12.setCount(deviceTimeDistributionDTO.getTwelvePeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel12);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel13 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel13.setHourPeriod(CommonConstants.THIRTEEN_HOUR_PERIOD);
//        deviceTimeDistributionExcel13.setCount(deviceTimeDistributionDTO.getThirteenPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel13);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel14 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel14.setHourPeriod(CommonConstants.FOURTEEN_HOUR_PERIOD);
//        deviceTimeDistributionExcel14.setCount(deviceTimeDistributionDTO.getFourteenPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel14);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel15 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel15.setHourPeriod(CommonConstants.FIFTEEN_HOUR_PERIOD);
//        deviceTimeDistributionExcel15.setCount(deviceTimeDistributionDTO.getFifteenPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel15);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel16 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel16.setHourPeriod(CommonConstants.SIXTEEN_HOUR_PERIOD);
//        deviceTimeDistributionExcel16.setCount(deviceTimeDistributionDTO.getSixteenPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel16);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel17 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel17.setHourPeriod(CommonConstants.SEVENTEEN_HOUR_PERIOD);
//        deviceTimeDistributionExcel17.setCount(deviceTimeDistributionDTO.getSeventeenPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel17);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel18 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel18.setHourPeriod(CommonConstants.EIGHTEEN_HOUR_PERIOD);
//        deviceTimeDistributionExcel18.setCount(deviceTimeDistributionDTO.getEighteenPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel18);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel19 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel19.setHourPeriod(CommonConstants.NINETEEN_HOUR_PERIOD);
//        deviceTimeDistributionExcel19.setCount(deviceTimeDistributionDTO.getNineteenPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel19);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel20 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel20.setHourPeriod(CommonConstants.TWENTY_HOUR_PERIOD);
//        deviceTimeDistributionExcel20.setCount(deviceTimeDistributionDTO.getTwentyPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel20);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel21 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel21.setHourPeriod(CommonConstants.TWENTYONE_HOUR_PERIOD);
//        deviceTimeDistributionExcel21.setCount(deviceTimeDistributionDTO.getTwentyOnePeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel21);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel22 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel22.setHourPeriod(CommonConstants.TWENTYTWO_HOUR_PERIOD);
//        deviceTimeDistributionExcel22.setCount(deviceTimeDistributionDTO.getTwentyTwoPeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel22);
//
//        DeviceTimeDistributionExcelDTO deviceTimeDistributionExcel23 = new DeviceTimeDistributionExcelDTO();
//        deviceTimeDistributionExcel23.setHourPeriod(CommonConstants.TWENTYTHREE_HOUR_PERIOD);
//        deviceTimeDistributionExcel23.setCount(deviceTimeDistributionDTO.getTwentyThreePeriod());
//        deviceTimeDistributionExcelList.add(deviceTimeDistributionExcel23);
//
//        return deviceTimeDistributionExcelList;
//
//    }
//
//
//}
